﻿@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "gvEditing";
        settings.KeyFieldName = "FLeaveID";
        settings.CallbackRouteValues = new { Controller = "LeaveAddition", Action = "LeaveListPartial" };
        settings.Width =System.Web.UI.WebControls.Unit.Percentage(96);

        settings.Columns.Add(column =>
        {
            column.Caption = "操作";
            column.SetDataItemTemplateContent(c =>
            {
                Html.DevExpress().HyperLink(s => { s.Name = "linkAudit" + c.VisibleIndex; s.Properties.Text = "审核"; s.Properties.ImageUrl = Url.Content("~/Content/ControlImages/button_Edit.png"); s.Properties.ClientSideEvents.Click = "function(){LeaveAudit('" + DataBinder.Eval(c.DataItem, "FLeaveID") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();

                        
            });
            column.Settings.AllowDragDrop = DefaultBoolean.False;
            column.Settings.AllowSort = DefaultBoolean.False;
            column.Width = 25;
        });


        settings.Columns.Add("FEmplName", "人员");
        settings.Columns.Add("strFAuditNote", "审核情况");
        settings.Columns.Add("FReason", "原因");
        settings.Columns.Add("ShowDate", "时间");
        settings.Columns.Add("FUpdDateStr", "更新时间");


        settings.SettingsBehavior.AllowSort = false;
        settings.SettingsBehavior.AllowDragDrop = false;
        settings.SettingsBehavior.AllowSelectByRowClick = false;
        settings.SettingsLoadingPanel.Text = "数据读取中...";
        settings.SettingsBehavior.AllowClientEventsOnLoad = false;
        settings.SettingsBehavior.AllowFocusedRow = true;


        settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                
        settings.CommandColumn.Visible = true;
        settings.CommandColumn.ShowSelectCheckbox = true;
        settings.CommandColumn.Width = System.Web.UI.WebControls.Unit.Pixel(5);

        settings.SettingsPager.Position = System.Web.UI.WebControls.PagerPosition.Bottom;
        settings.SettingsPager.FirstPageButton.Visible = true;
        settings.SettingsPager.LastPageButton.Visible = true;
        settings.SettingsPager.PageSize = ElingOA6_Admin_DSJCJ.Common.GlobalConstant.CONSTRING_PAGESIZE;
        settings.SettingsPager.AlwaysShowPager = true;

        settings.CommandColumn.SetHeaderTemplateContent(c =>
        {
            Html.DevExpress().CheckBox(settingsCheckBox =>
            {
                settingsCheckBox.Name = "cbSelectAll";
                settingsCheckBox.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ if(s.GetChecked()) {0}.SelectAllRowsOnPage(); else {0}.UnselectAllRowsOnPage(); }}", settings.Name);

                if (c.Grid.VisibleRowCount == 0)
                {
                    settingsCheckBox.Enabled = false;

                }
                else
                {
                    settingsCheckBox.Checked = c.Grid.VisibleRowCount == c.Grid.Selection.Count;
                }


            }).Render();
        });
                                
                
        settings.PageIndexChanged = (sender, e) =>
        {
            ASPxGridView grid = (ASPxGridView)sender;
            grid.Selection.UnselectAll();
        };
                
                
                
    }).Bind(Model).GetHtml()